<?php
define('IN_MOBILE', true);

wl_load()->func('template');
wl_load()->model('permissions');
global $_W, $_GPC;
$controller = $_GPC['do'];
$action = $_GPC['ac'];
$op = $_GPC['op'];
//file_get_contents(app_url("home/task"));
//$moblile_uid=pdo_fetch("select uid from ". tablename('uni_account_users')." where uniacid = '{$_W['uniacid']}' and role='owner' ");
//$checkmobile=pdo_fetch("select mobile from ". tablename('users_profile')." where uid = '{$moblile_uid['uid']}'  ");

if (empty($controller) || empty($action)) {
    $_GPC['do'] = $controller = 'store';
    $_GPC['ac'] = $action = 'setting';
}
/*
$roots = 'www.huodiesoft.com';
$root_url = "http://" . $_W['uniaccount']['key'] . "." . $roots . "/" . 'app/index.php?i=' . $_W['uniacid'] . '&c=entry&m=lexiangpingou&';

$uni = pdo_fetchall("select vip,endtime,ordernum,uniacid from " . tablename('account_wechats') . ' where vip=:vip and endtime<:endtime ', array(':vip' => 1, ':endtime' => time()));
foreach ($uni as $key => $value) {
    pdo_update('account_wechats', array('vip' => 0), array('uniacid' => $value['uniacid']));
}
$acct = pdo_fetch("select * from " . tablename('account_wechats') . " where  uniacid = '{$_W['uniacid']}'");
if (empty($acct['tpl'])) {
    pdo_update('account_wechats', array('tpl' => 8146), array('uniacid' => $_W['uniacid']));
}

*/
isetcookie('__uniacid', $_W['uniacid'], 7 * 86400);

isetcookie('__uid', $_W['uid'], 7 * 86400);
if (empty($_W['uniacid'])) {
    header("Location: index.php?c=user&a=login&");
    exit;
}
/*
$paylist=pdo_fetchall("SELECT * from cm_tg_order where uniacid=91 and  `status`=10 and transid ='' ");
foreach ($paylist as $key3 => $value) {
	$paylog=pdo_fetch("SELECT * from cm_core_paylog where tid=:tid",array(':tid'=>$value['orderno']));
	$params=unserialize($paylog['tag']);
	pdo_update('tg_order', array('transid'=>$params['transaction_id']), array('orderno' => $paylog['tid']));
}*/
//$notification=pdo_fetchall("select id,title,summary,FROM_UNIXTIME(stime,'%Y-%m-%d ') as stime from".tablename('tg_notification')." ORDER BY id DESC LIMIT 0,5");

$getlistFrames = 'get' . $controller . 'Frames';
$frames = $getlistFrames();
$top_menus = get_top_menus();
/*
$funrecordlist=pdo_fetchall("SELECT * from ims_tg_function_detail where uniacid={$_W['uniacid']} ");
if(empty($funrecordlist))
{
	$funlist=pdo_fetchall("SELECT * from ims_tg_function where isdingzhi<>1 and type<>3");
	
	foreach ($funlist as $key3 => $value) {
		if($value['id']==8146)
		{
			$endtime=strtotime(date('Y-m-d', strtotime('+240 month')));
		}else{
			$endtime=strtotime(date('Y-m-d', strtotime('+7 day')));
		}
	$data = array(
		'uniacid'     => $_W['uniacid'],
		'functionid'=>$value['id'],
		'endtime'=>$endtime
	);
	pdo_insert('tg_function_detail', $data);
}
}
$funde=pdo_fetch("SELECT * from ims_tg_function_detail where uniacid=:uniacid and functionid=8146", array(':uniacid' => $_W['uniacid']));
if($funde['endtime']<1609257600)
{
	pdo_update('tg_function_detail', array('endtime'=>1609257600), array('uniacid' => $_W['uniacid'],'functionid'=>8146));
}
 
if(empty($funde))
{
	$endtime=strtotime(date('Y-m-d', strtotime('+240 month')));
	$datas = array(
		'uniacid'     => $_W['uniacid'],
		'functionid'=>8146,
		'endtime'=>$endtime
	);
	pdo_insert('tg_function_detail', $datas);
}
*/
$file = TG_WEB . 'controller/' . $controller . '/' . $action . '.ctrl.php';

if (!file_exists($file)) {
	
    header("Location: index.php?i={$_W['uniacid']}&c=entry&do=home&ac=index&m=lexiangpingou");
    exit;
}
require_once $file;